from django.db import models


# Create your models here.


class Orders(models.Model):
    TYPE_CHOISE = (
        (1, 'vip'),
        (2, 'course')
    )
    # user,type(商品类型, 1:vip, 2:course) 商品(vip_id, course_id), 价格,金额, 订单号, 下单时间, 支付时间, 订单
    user = models.ForeignKey('user.User', on_delete=models.SET_NULL, null=True)
    type = models.IntegerField('商品类型', choices=TYPE_CHOISE, default=1)
    vip = models.ForeignKey('user.Vip', on_delete=models.SET_NULL, null=True)
    courser = models.ForeignKey('course.Course', on_delete=models.SET_NULL, null=True)
    order_id = models.CharField('订单号', max_length=64)
    alipay_order_id = models.CharField('支付宝订单号', max_length=64)
    amount = models.DecimalField('金额', max_digits=10, decimal_places=2)
    order_time = models.DateTimeField('下单时间', auto_now_add=True)
    pay_time = models.DateTimeField('支付时间', null=True)
    subject = models.CharField('商品主题', max_length=64)


    class Meta:
        db_table = 'tb_orders'
